<?php 
/**
 *
 * @category    API
 * @package     Api_Company
 * @subpackage  Model
 * @author      trungpm
 */
class Api_Model_SecurityRoles {
    /* get all security roles
     * author: trungpm
     */
    function GetSecurityRolesList($user, $password) {
        $Errors = array();
        $db = db($user, $password);
        if (gettype($db) == 'integer') {
            $Errors[0] = NoAuthorisation;
            return $Errors;
        }
        $sql = 'SELECT secroleid, secrolename FROM securityroles';
        $result = DB_query($sql, $db);
        while ($myrow = DB_fetch_array($result)) {
            $SecurityRolesList[$myrow['secroleid']] = $myrow['secrolename'];
        }
        DB_free_result($result);
        return $SecurityRolesList;
    }
    
	/* Get Secrole by Id.
     * author: trungpm
     */
    function GetSecroleById($SecroleId, $user, $password) {
    	$Errors = array();
        $db = db($user, $password);
        if (gettype($db) == 'integer') {
            $Errors[0] = NoAuthorisation;
            return $Errors;
        }
        $sql = 'SELECT secroleid,		
					secrolename
				FROM securityroles WHERE secroleid=\''. $SecroleId . '\'';
        $result = DB_Query($sql, $db);
        if (sizeof($Errors) == 0) {
            $arrResult = DB_fetch_array($result);
            DB_free_result($result);
            return $arrResult;
        } else {
            return $Errors;
        }
    }
}
?>
